/*****转盘活动******/
function rePlay(){   //再玩一遍
    $('#enter10').fadeOut(200);
    lottery();
};
function showTrunteble(){  //显示大转盘
    $("#enter8").show();
}

function showRule(){  //显示大转盘规则
    $("#enter9").show();
}

function returnClose(idName){ //返回按钮关闭
    $(idName).hide();
}
function changProduct(){  //刷新惊喜
    $("#rotatebtn").rotate({
        duration:0, //转动时间
        angle: 0,
        animateTo:0, //转动角度
        easing: $.easing.easeOutSine,
        callback: function(){
        }
    });
    var browser=navigator.appName

    var b_version=navigator.appVersion

    var version=b_version.split(";");
    if(version[1]==undefined){
        var trim_Version="火狐";
    }else{
        var trim_Version=version[1].replace(/[ ]/g,"");
    }

    var typeId=parseInt($('.turntable').attr('id'));
    var arr1=[  //刷新惊喜更换奖品   \ie8
        "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='http://hlxntest.mypeugeot.com.cn/Public/images/bg_bz1.png',sizingMethod='scale')",
        "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='http://hlxntest.mypeugeot.com.cn/Public/images/bg_bz2.png',sizingMethod='scale')",
        "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='http://hlxntest.mypeugeot.com.cn/Public/images/bg_bz3.png',sizingMethod='scale')",
    ];

    var arr2=[  //刷新惊喜更换奖品  \ie8+,ff
        "url(./Public/images/bg_bz1.png)",
        "url(./Public/images/bg_bz2.png)",
        "url(./Public/images/bg_bz3.png)",
    ];
    if(trim_Version=="MSIE8.0" || trim_Version=="MSIE9.0")
    {
        if(typeId==3){
            $('.turntable').attr('id',1);
            $('#disk').css("filter",arr1[0]);
            $('#enterCha').fadeIn(20).delay(1500).fadeOut();

        }else{
            $('.turntable').attr('id',typeId+1);
            $('#disk').css("filter",arr1[typeId]);
            $('#enterCha').fadeIn(20).delay(1500).fadeOut();
        }

    }else{
        if(typeId==3){
            $('.turntable').attr('id',1);
            $('#disk').css("background-image",arr2[0]);
            $('#enterCha').fadeIn(20).delay(1500).fadeOut();

        }else{
            $('.turntable').attr('id',typeId+1);
            $('#disk').css("background-image",arr2[typeId]);
            $('#enterCha').fadeIn(20).delay(1500).fadeOut();
        }
    }
      $("#enter10").hide();

};

$(function(){  //点击按钮开始抽奖
    $("#start").click(function(){
        lottery();
    });
});

/**
 *@param typeId  奖品类型，1、第一组奖品，2、第二组奖品，3、第三组奖品
 */
function lottery(){   //抽奖请求后台随机角度和奖项
    var typeId=parseInt($('.turntable').attr('id'));
    $("#start").unbind('click');
    $.ajax({
        type: "GET",
        url: "index.php?m=Home&c=Lotto&a=Do_lotto_options",
        dataType: "json",
        data:{'group':typeId},   //给后台提交当前积分和转盘奖品类型
        cache: false,
        success:function(json){
           $("#rotatebtn").unbind('click').css("cursor","default");
            var a = json.angle; //角度
            var p = json.PNAME; //奖项
            var status = json.status; //奖项
            var score = json.score; //积分
            var str = "";   //中奖提示语字符串
         if(status==500){
             $("#showLottoText").text("");
             $("#showLottoText").text(json.msg);
             $("#enter11").show();   //提示框
             $("#start").bind('click',lottery);
             return;
         }
                $("#rotatebtn").rotate({
                    duration:4000, //转动时间
                    angle: 0,
                    animateTo:-1800-a, //转动角度
                    easing: $.easing.easeOutSine,
                    callback: function(){
                        if(status==200)
                        {
                            str="中奖啦！<br>"+p+"就是你的了!";
                            $("#score").html(score);
                            $("#enter10").show();
                            $('.tip_msg').html(str);
                            $("#start").bind('click',lottery);
                        }else{
                            str="很可惜<br/>Try Again !";
                            $("#score").html(score);
                            $("#enter10").show();
                            $('.tip_msg').html(str);
                            $("#start").bind('click',lottery);
                        }
                    }
                });

        },
        error: function(XMLHttpRequest, textStatus, errorThrown){
            $('#enter12').fadeIn(10).delay(1000).fadeOut();
            $("#start").bind('click',lottery);
            return false;
        },
    });
}

/*****转盘活动******/
